Using Git and Github
April 1, 2025
Compiled software are a bunch of files. At each software improvment, developers want the software to be stable with no regression. For that, they have to know what files have changed between snapshots.
add & commitadd & commitadd & commitadd & commitadd & commitadd & commitbranchesbranchesmain par défault): c’est un série de commentaires (commit)commit) est ce que l’on appelle la tête de la branche (HEAD), elle contient la version la plus à jour des fichiers.commit) est attachée une version des fichiers.local vs remotegit init)git add)git commit)git fetch & git push)git fetch & git pull)git —versiongit configFor more details: https://happygitwithr.com/install-git
In order to reduce the learning curve, we will learn R Studio of interacting with git
So many other ways to interact with git:
gert packageAll the key concepts and process still the same!
To use git in Rstudio, you need to create a new Project. Let’s start by creating our project directory.
Open RStudio, in the top right corner create a new project
You can now look under the git tab, you should see this:
Create a new file: go to the menu File => New file => R Script. Make sure to save it with the name script_1.R.
What happens in the git tab?
This is as simple as “checking off” the file in the Git tab. This is called Staging the file.
What is a gitignore? A gitignore is a file that lists the file you never want git to track. It can match certain file names (for instance, .csv or .tif files). This can be useful in case you need to make sure certain files (like data files or large files), do not get added.
Click on commit on the top of the file list. This window should appear:
Before committing anything you need to add a commit message. It is important to add a useful message to your commit, a bit like a journal entry, so that you can remember what you committed.
Click on commit in order to commit the changes!
Note that once you have staged a file, you could do more changes, and you would need to re-run git add to add them to the index. Those changes not yet fully registered by git, they are like a draft, not until you commit. When you want to take a snapshot of a file, it means you are ready to commit that change to the index.